#include <iostream>
#include <vector>
using namespace std;
class Robot{
private:
    int row;
    int col;
    int threshold;
    vector<bool> visited;
    int count;
public:
    Robot(int r,int c,int t);
    void Movingcount(int c,int r);
    void setVisted(int c,int r);
    bool isVisited(int c,int r);
    bool check(int c,int r);
    int sum_index(int n);
    void show();
};
int Robot::sum_index(int nums) {
    int sums=0;
    while(nums>0)
    {
        sums+=nums%10;
        nums/=10;
    }
    return sums;
}
Robot::Robot(int r, int c,int t) {
    count = 0;
    row = r;
    col = c;
    visited = vector<bool>(row*col);
    threshold = t;

}
bool Robot::isVisited(int c, int r) {
    return visited[r*col+c];
}
void Robot::setVisted(int c, int r) {
    visited[r*col+c] = true;

}
bool Robot::check(int c, int r) {
    if(c<0||c>=col||r<0||r>=row||isVisited(c,r)||c<r)
        return false;
    else
        return true;
}
void Robot::Movingcount(int c, int r) {
    if(check(c,r))
    {
        count++;
        setVisted(c,r);
        Movingcount(c-1, r);
        Movingcount( c+1,  r);
        Movingcount( c, r-1);
        Movingcount( c, r+1);
    }

}

void Robot::show() {
    cout<<"当前行数为:"<<row<<"\n";
    cout<<"当前列数为:"<<col<<"\n";
    cout<<"当前统计的count为:"<<count<<"\n";
}

int main() {
    int threshold = 18;
    int rows = 2,cols=2;
    Robot R = Robot(rows,cols,threshold);
    R.Movingcount(0,0);
    R.show();
    return 0;
}

